<template>
  <a-spin :spinning="confirmLoading" >
  <div class="container">


        <div class="auto">
<!--          <div class="det_bar clearfix wow fadeInDown animated" data-wow-delay="0.1s">-->
<!--            <div class="crumb fl">-->
<!--              <span>留言详情</span>-->
<!--            </div>-->
<!--            <a-button style="float: right;" @click="goBack" icon="rollback">返回</a-button>-->
<!--          </div>-->
          <div class="pub_tit det_bar clearfix wow fadeInDown animated" data-wow-delay="0.1s">
            <em class="bt">留言详情</em>
            <a-icon style="float: left; margin-top: 16px; margin-right: 8px; cursor: pointer" type="rollback" @click="goBack"/>
          </div>
          <div class="det_wrap">
            <div class="topbox">
              <a-button type="primary" style="position: absolute; right: 50px;" @click="deleteMessage" v-if="isShowBtnPersson()">删除</a-button>
              <h6 class="title">{{messageDetail.title}}</h6>
              <div class="sm">

                <span class="fz admin">{{messageDetail.email}}</span>
              </div>

            </div>
            <div class="editbox wow fadeInUp animated" data-wow-delay="0.1s">
              <p v-html="messageDetail.content"></p>
            </div>
            <div class="botbox wow fadeInUp animated" data-wow-delay="0.1s">

              <span class="date fr">发布于 {{messageDetail.createDate}}</span>
            </div>
          </div>
        </div>


  </div>
  </a-spin>
</template>

<script>
import '../../../public/css/style.css';
import { getAction, postAction } from '@/api/manage'
import { isShowBtn } from "@/utils/authFilter"
export default {
  name: 'DailyActivities',
  // beforeRouteEnter (to, from, next) {
  //   window.scrollTo(0, 0);
  //   next();
  // },
  data () {
    return {
      messageDetail: {},
      confirmLoading: false
    };
  },
  created() {
    this.getMessageDetail()
  },
  methods: {
    isShowBtnPersson() {
      return isShowBtn()
    },
    deleteMessage() {
      let self = this
      this.$confirm({
        title: "确认删除",
        content: "是否删除该条留言?",
        onOk: function () {
          self.confirmLoading = true
          postAction('/messagebook/delete', {ids: self.messageDetail.id}).then((res) => {
            if (res.code ==0) {
              self.$router.push('/messageBook')
              self.$message.success(res.msg)
            } else {
              self.$message.warning(res.msg);
            }
          }).finally(() => {
            self.confirmLoading = false
          });
        }
      });
    },
    goBack() {
      this.$router.go(-1)
    },
    getMessageDetail() {
      let self = this
      this.confirmLoading = true
      let url = '/messagebook/info/' + this.$route.query.id
      getAction(url, {}).then(res => {
        if(res.code == 0) {
          self.messageDetail = Object.assign({}, res.result)
        } else {
          self.$message.error(res.msg)
        }
      }).finally(() => {
        self.confirmLoading = false
      })
    }
  }
};
</script>

<style lang="less" scoped>
  .no-data {
      color: rgba(0, 0, 0, .25);
      text-align: center;
      line-height: 64px;
      font-size: 16px;

      i {
        font-size: 24px;
        margin-right: 16px;
        position: relative;
        top: 3px;
      }
    }
</style>
